Bundle LLM guide files in wheel with get_llm_guide() accessor#310
Bundle LLM guide files in wheel with get_llm_guide() accessor#310
Conversation
Move docs/llms*.txt into diff_diff/guides/ so they ship inside the wheel and are discoverable via `diff_diff.get_llm_guide()` with no network access. Surface the helper in the module docstring so help(diff_diff) guides AI agents to it. - Move llms.txt, llms-full.txt, llms-practitioner.txt to diff_diff/guides/ - Add get_llm_guide(variant) using importlib.resources - Explicit [tool.maturin] include entry for defense-in-depth across 1.4-2.0 - Switch pyproject "Practitioner Guide" URL to ReadTheDocs - Rewrite internal cross-refs inside guide files to point at the accessor - Update docs/conf.py html_extra_path to the new location (adds llms-practitioner.txt to the RTD surface) - Update all path references (doc-deps.yaml, README, CLAUDE, REGISTRY, bump-version) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Clarifies that "CONCISE", " concise", etc. raise ValueError so callers don't have to discover this by experimentation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Overall Assessment ✅ Looks good — no unmitigated P0/P1 findings. This PR is packaging/docs/API-surface work only. No estimator math, weighting, variance/SE, identification checks, or default behaviors changed. Execution-based validation was not possible in this environment because Executive Summary
Methodology No findings. Affected method(s): none. The REGISTRY change at docs/methodology/REGISTRY.md:L2770 is path-only and preserves the existing Baker et al. adaptation note. Code Quality No findings. Performance No findings. The new code path is an explicit on-demand text read, not estimator-path logic. Maintainability No findings. Tech Debt
Security No findings. Documentation/Tests
|
The guide's opening blockquote previously pointed at `docs/methodology/REGISTRY.md` for details on reorganizations relative to Baker et al. (2025). That path does not exist inside a wheel-only install, so it was a dead breadcrumb for offline AI agents - exactly the scenario this PR is meant to fix. Inline the four deviation bullets (numbering, PT as Step 3, uncertainty folding into Step 5, Step 8 = Robustness & Reporting) directly into the guide so it is self-contained. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good No unmitigated P0/P1 findings. This re-review resolves the earlier dead offline-breadcrumb issue. The only remaining item I found is a tracked Executive Summary
Methodology Affected method(s): none. Severity: Code Quality No findings. Performance No findings. The new guide read in diff_diff/_guides_api.py:L13-L48 is on-demand and outside estimator/inference hot paths. Maintainability No findings. Tech Debt Severity: Security No findings. The new accessor uses a fixed variant whitelist instead of interpolating user input into filesystem paths in diff_diff/_guides_api.py:L6-L48. Documentation/Tests No new untracked findings. The added coverage in tests/test_guides.py:L10-L67 is reasonable for variant loading, invalid inputs, namespace export, and docstring surfacing, and the earlier offline-breadcrumb issue is fixed by diff_diff/guides/llms-practitioner.txt:L3-L20. Verification note: I could not run the tests here because importing |
maturin 1.13.1's GlobPattern enum only accepts `sdist` or `wheel` for the `format` field, not `all`. That rejected pyproject.toml at line 97 and broke the build step in every Python Tests job on the PR. Use the bare-string form `include = ["diff_diff/guides/*.txt"]`, which includes the glob in both sdist and wheel by default. Verified locally with `maturin sdist`: all three .txt files land in the sdist tarball. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good No unmitigated P0/P1 findings. This re-review stays clear of estimator, weighting, variance/SE, identification-assumption, and default-behavior changes. The only issues I found are non-blocking P3 items around docs/dependency tracking and release validation. Executive Summary
Methodology
Code Quality No findings. Performance No findings. Maintainability
Tech Debt
Security No findings. The accessor dispatches through a fixed whitelist rather than interpolating user input into filesystem paths in diff_diff/_guides_api.py:L6. Documentation/Tests No new untracked findings. Coverage in tests/test_guides.py:L10 is reasonable for variant loading, invalid inputs, namespace export, and docstring surfacing. Verification note: I could not run |
…ides PR #309 added four validation diagnostics to SyntheticDiDResults: `get_weight_concentration()`, `get_loo_effects_df()`, `in_time_placebo()`, and `sensitivity_to_zeta_omega()`. Because this PR is the first place the guides ship inside the wheel, we want them faithful to main's API at the moment of merge. - `llms-full.txt`: add the four methods to the SyntheticDiDResults Methods line and a short "Validation diagnostics" subsection describing each. - `llms-practitioner.txt`: split the former `SyntheticDiD/TROP` bullet so SyntheticDiD now points at the built-in helpers (with the jackknife caveat for LOO); TROP keeps the generic guidance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Executive Summary
Methodology
Code Quality No findings. Performance No findings. Maintainability
Tech Debt
Security No findings. Documentation/Tests
|
AI review flagged that the bullet said "per treated unit" and implied a treated-side-only support condition, but the method actually returns a DataFrame with both control and treated rows and has a broader set of availability conditions than a single clause captures. - Change "per treated unit" to "per-unit (both control and treated rows)" - Defer the full availability conditions to the method docstring, with examples of the two most common failure modes (single treated unit, only one control with nonzero effective weight) Code behavior unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Executive Summary
Methodology No findings. Affected methods: none. The only methodology-adjacent change is guide prose, and its explicit deviations from Baker et al. remain documented in both diff_diff/guides/llms-practitioner.txt:L3-L20 and docs/methodology/REGISTRY.md:L2782-L2797. Code Quality No findings. Performance No findings. Maintainability
Tech Debt
Security No findings. Documentation/Tests
|
- diff_diff/guides/llms-practitioner.txt: add reversible-treatment branch to the Step 4 decision tree pointing at ChaisemartinDHaultfoeuille (alias DCDH), and a short Step 5 example showing the survey_design + L_max + TSL fallback for dCDH. The practitioner guide previously had zero dCDH coverage despite the full API being live. - diff_diff/guides/llms-full.txt: fix stale SyntheticDiDResults table (line 1024) — variance_method now accepts "bootstrap", "jackknife", or "placebo" (jackknife was added for synthdid::vcov parity but the table only listed bootstrap/placebo). Bundled-guide paths only. The old docs/llms-*.txt were moved to diff_diff/guides/ in main (PR #310); these edits target the new canonical location consumed by get_llm_guide(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
docs/llms*.txtintodiff_diff/guides/so the three LLM guide files ship inside the wheel and are discoverable with no network access.diff_diff.get_llm_guide(variant)accessor usingimportlib.resources; variants:"concise"(default),"full","practitioner".help(diff_diff)via the module docstring so AI agents find it from apip installalone.[tool.maturin] includeentry as defense-in-depth against auto-inclusion behavior drift across maturin 1.4-2.0.diff_diff.get_llm_guide("practitioner")so the air-gap breadcrumb works end-to-end.pyproject.toml"Practitioner Guide" URL switched to ReadTheDocs (newly publishesllms-practitioner.txtat/en/stable/llms-practitioner.txt).README.md,CLAUDE.md,docs/doc-deps.yaml,docs/methodology/REGISTRY.md, and.claude/commands/bump-version.md.Methodology references (required if estimator / math changes)
REGISTRY.mdupdate is a path reference only (points at the moved practitioner guide).Validation
tests/test_guides.py— 18 tests (variant loading, default=concise, full>concise>practitioner length, content-stability assertions, UTF-8 encoding roundtrip, package-resource equivalence, error path for 7 invalid variants, namespace export, docstring hint).pytest tests/test_guides.py -v→ 18/18 passing locally.python -c "import diff_diff; help(diff_diff)"shows the AI-agent hint;get_llm_guide(),get_llm_guide("full"),get_llm_guide("practitioner")return 13166 / 56793 / 19807 chars respectively.html_extra_pathresolves; wheel-install smoke verifying.txtfiles are inside the built artifact; live check that the new RTD URL resolves after docs deploy.Security / privacy